ShortcutKey2URL: 2QUOTE4DLT
code: script.js
/* いつもお世話になっているクリップボードコピースニペット */
window.COPY_TO_CLIPBOARD = window.COPY_TO_CLIPBOARD ?? {};
window.COPY_TO_CLIPBOARD.exec = text => retryCount => {
const textarea = document.createElement('textarea');
textarea.textContent = text;
const body = document.querySelector('body');
body.appendChild(textarea);
textarea.select();
const copied = new Array(1 + retryCount).fill().reduce((prev, curr, i) => {
const count = i + 1;
if (prev) return true;
console.log(Try copying: ${count} time${i?'s':''});
/* 'copy'が機能しないページがあるため'cut'に変更 */
return document.execCommand('cut');
}, false);
body.removeChild(textarea);
return copied;
};
/* デライトに貼り付ける描出 */
window.URL_INFO = window.URL_INFO ?? {};
window.URL_INFO.createQuote = () => {
const quote = window.getSelection().toString();
const link = [${document.title} ${window.location.href}];
const quotedText = >>\n${quote}\n--${link};
return ${quote.trim() ? quotedText : link}\n;
};
window.URL_INFO.findBgForMyPage = (myPage) =>
window.open(https://dlt.kitetu.com/?fg=${encodeURIComponent(myPage)}&kw=%26${encodeURIComponent(document.title.trim())});
window.URL_INFO.findKname = (kname) =>
window.open(https://dlt.kitetu.com/?kw=%26${encodeURIComponent(kname)}#sgn_drw);
/* コピー */
window.COPY_TO_CLIPBOARD.exec(window.URL_INFO.createQuote())(0);
/* マイ自由帳を開いて検索する */
window.WINDOW_INFO = window.WINDOW_INFO ?? {};
/*
window.WINDOW_INFO.childWindow = window.URL_INFO.findBgForMyPage('K#9-804C/A-C4EA');
*/
/* 検索する */
window.WINDOW_INFO.childWindow = window.URL_INFO.findKname('訪問したページ');
/* 外部サイトだと同一オリジンポリシー違反により、childWindowの中身を参照できず、これ以上の操作は不可能 */